import 'package:flutter/material.dart';
import 'package:huajianshe_app/common/C.dart';
import 'package:huajianshe_app/common/TS.dart';
import 'package:huajianshe_app/common/load_image.dart';
import 'package:huajianshe_app/common/space.dart';
import 'package:huajianshe_app/widget/RoundedCornerWidget.dart';
import 'package:huajianshe_app/widget/SmartButton.dart';

class ShareDialog extends StatelessWidget {
  
  final int shareTypes;

  const ShareDialog({Key? key, 
    this.shareTypes = 31
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(mainAxisSize: MainAxisSize.min, children: [
      RoundedCornerWidget(backgroundColor: C.grayF6, borderWidth: 0, cornerPosition: 3, radius: 13,
        child: Column(mainAxisSize: MainAxisSize.min, children: [
          H(16),
          Text('分享至', style: TS(14, C.gray333),),
         
          Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
            ...buildShareWidgets()
          ])
        ]),
      ),
      SmartButton(width: double.infinity, height: 48, text: '取消', fontSize: 15, textColor: C.gray333, backgroundColor: Colors.white,
      radius: 13, cornerPosition: 12, borderColor: Colors.transparent,)
    ]);
  }
  
  List<Widget> buildShareWidgets() {
    List<Widget> result = [];
    print('${shareTypes & ShareType.CIRCLE}');
    if (shareTypes & ShareType.CIRCLE == ShareType.CIRCLE) {
      result.add(SmartButton(text: '圈子好友', fontSize: 12, textColor: C.gray666, backgroundColor: Colors.transparent,
        height: 100, width: 50, borderColor: Colors.transparent, drawablePadding: 2,
        drawableTop: LoadImage('ic_share_circle')));
    }
    if (shareTypes & ShareType.WECHAT == ShareType.WECHAT) {
      result.add(SmartButton(text: '微信', fontSize: 12, textColor: C.gray666, backgroundColor: Colors.transparent,
          height: 100, width: 50, borderColor: Colors.transparent, drawablePadding: 2,
          drawableTop: LoadImage('ic_share_wechat')));
    }
    if (shareTypes & ShareType.WECHAT_MOMENT == ShareType.WECHAT_MOMENT) {
      result.add(SmartButton(text: '朋友圈', fontSize: 12, textColor: C.gray666, backgroundColor: Colors.transparent,
          height: 100, width: 50, borderColor: Colors.transparent, drawablePadding: 2,
          drawableTop: LoadImage('ic_share_wechat_moment')));
    }
    if (shareTypes & ShareType.POSTER == ShareType.POSTER) {
      result.add(SmartButton(text: '分享海报', fontSize: 12, textColor: C.gray666, backgroundColor: Colors.transparent,
          height: 100, width: 50, borderColor: Colors.transparent, drawablePadding: 2,
          drawableTop: LoadImage('ic_share_poster')));
    }
    if (shareTypes & ShareType.COPY_LINK == ShareType.COPY_LINK) {
      result.add(SmartButton(text: '复制链接', fontSize: 12, textColor: C.gray666, backgroundColor: Colors.transparent,
          height: 100, width: 50, borderColor: Colors.transparent, drawablePadding: 2,
          drawableTop: LoadImage('ic_share_copy_link')));
    }
    return result;
  }
  
}

class ShareType {
  static const int CIRCLE = 1; //圈中好友
  static const int WECHAT = 2; //微信
  static const int WECHAT_MOMENT = 4; //朋友圈
  static const int POSTER = 8; // 分享海报
  static const int COPY_LINK = 16; // 复制链接
}